package com.example.db2dm.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@ConfigurationProperties(prefix = "migration")
public class MigrationProperties {
    
    /**
     * 源数据库配置
     */
    private DatabaseConfig source = new DatabaseConfig();
    
    /**
     * 目标数据库配置
     */
    private DatabaseConfig target = new DatabaseConfig();
    
    /**
     * 需要迁移的表列表
     */
    private List<String> tables;
    
    /**
     * 需要排除的表列表
     */
    private List<String> excludeTables;
    
    /**
     * 批量处理大小
     */
    private int batchSize = 1000;
    
    /**
     * 重试次数
     */
    private int retryCount = 3;
    
    // Getters and Setters
    
    public DatabaseConfig getSource() {
        return source;
    }
    
    public void setSource(DatabaseConfig source) {
        this.source = source;
    }
    
    public DatabaseConfig getTarget() {
        return target;
    }
    
    public void setTarget(DatabaseConfig target) {
        this.target = target;
    }
    
    public List<String> getTables() {
        return tables;
    }
    
    public void setTables(List<String> tables) {
        this.tables = tables;
    }
    
    public List<String> getExcludeTables() {
        return excludeTables;
    }
    
    public void setExcludeTables(List<String> excludeTables) {
        this.excludeTables = excludeTables;
    }
    
    public int getBatchSize() {
        return batchSize;
    }
    
    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }
    
    public int getRetryCount() {
        return retryCount;
    }
    
    public void setRetryCount(int retryCount) {
        this.retryCount = retryCount;
    }
    
    public static class DatabaseConfig {
        private String url;
        private String username;
        private String password;
        private String type; // oracle, mysql, dm
        
        // 保留旧的配置字段以保持向后兼容性
        private String host;
        private int port;
        private String database;
        private String serviceName;
        
        // Getters and Setters
        
        public String getUrl() {
            return url;
        }
        
        public void setUrl(String url) {
            this.url = url;
        }
        
        public String getUsername() {
            return username;
        }
        
        public void setUsername(String username) {
            this.username = username;
        }
        
        public String getPassword() {
            return password;
        }
        
        public void setPassword(String password) {
            this.password = password;
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        // 以下为向后兼容的字段
        
        public String getHost() {
            return host;
        }
        
        public void setHost(String host) {
            this.host = host;
        }
        
        public int getPort() {
            return port;
        }
        
        public void setPort(int port) {
            this.port = port;
        }
        
        public String getDatabase() {
            return database;
        }
        
        public void setDatabase(String database) {
            this.database = database;
        }
        
        public String getServiceName() {
            return serviceName;
        }
        
        public void setServiceName(String serviceName) {
            this.serviceName = serviceName;
        }
    }
}